package com.example.login.Mapper;

import com.example.login.Pojo.Address;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;
import org.springframework.stereotype.Repository;

import java.util.ArrayList;

@Repository
@Mapper
public interface AddressMap {
    @Insert("INSERT INTO `xtshop_address`(user_id,user_name,tel,province,city,county,all_address,address_tag)" +
            "VALUES(#{user_id},#{user_name},#{tel},#{province},#{city},#{county},#{all_address},#{address_tag})")
    void AddAddress(int user_id,String user_name,String tel,String province,String city,String county,String all_address,
                    int address_tag);
    @Select("Select * from xtshop_address where user_id=#{user_id} order by address_tag desc;")
    ArrayList<Address> getAddress(int user_id);
    @Update("update xtshop_address set address_tag=0 where user_id=#{user_id}")
    void update(int user_id);
    @Update("update xtshop_address set address_tag=1 where user_id=#{user_id} and id=#{id}")
    void updateTag(int user_id,int id);
}
